#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

int main()
{
	string str;
	while(getline(cin,str))
	{
		//getchar();
		char ch;
		int ans=0;
		cin>>ch;
		if(ch>='a'&&ch<='z') ch=ch-('a'-'A');
		for(int i=0;i<str.length();i++)
		{
			if(str[i]>='a'&&str[i]<='z') str[i]=str[i]-('a'-'A');
			if(str[i]==ch) ans++;
		}
		cout<<ans<<endl;
		getchar();
	}
} 
